#include "vconsole.h"
#include <iostream>
#include "defs.h"

vconsole::vconsole()
{
}

vconsole::~vconsole()
{
}

void vconsole::prepare_prefix(std::string &str)
{
    size_t len = str.size();

    if (len < CONSOLE_PREFIX_LEN)
    {
        size_t dif = CONSOLE_PREFIX_LEN - len;

        while(dif--)
        {
            str += std::string(" ");
        }
    }
    
    str += std::string(": ");
}

void vconsole::print_message(const char *msg, const char *prefix)
{
    std::string preStr(prefix);
    prepare_prefix(preStr);
    std::cout << preStr << msg << std::endl;
}

void vconsole::print_status(const char *msg, const char *prefix, bool st)
{
    std::string status;
    std::string preStr(prefix);
    prepare_prefix(preStr);

    if (st)
    {
        status = std::string(OK);
    }
    else
    {
        status = std::string(FAIL);
    }

    std::cout << preStr << msg << "  [" << status  << "]" << std::endl;
}

